package com.hos.hospital.controller;


import com.github.pagehelper.PageInfo;
import com.hos.hospital.entity.Admin;
import com.hos.hospital.entity.Banners;
import com.hos.hospital.entity.Doctor;
import com.hos.hospital.entity.Section;
import com.hos.hospital.service.AdminService;
import com.hos.hospital.service.BannersService;
import com.hos.hospital.service.DoctorService;
import com.hos.hospital.service.MessagesService;
import com.hos.hospital.service.PatientService;
import com.hos.hospital.service.SectionService;
import com.hos.hospital.service.impl.DoctorServiceImp;
import com.hos.hospital.utils.ExcelInput;
import com.hos.hospital.utils.ExcelUtils;
import com.hos.hospital.utils.StringRandom;

import org.apache.ibatis.jdbc.Null;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 * 后端管理员控制层
 */
@Controller
@RequestMapping("/admin")
public class AdminController {

 
    private Integer size  = 6;//每页显示数量
    

    @Value("${fileUrl}") //在配置文件中获取文件的保存路径
    private String filePath;

    @Autowired
    private  DoctorServiceImp  ds;
    
	    /**
	     * 后台登陆界面
	*/
	@RequestMapping("/index")
	public String index(Model model,Doctor doctor,@RequestParam(value = "page", defaultValue = "0") int page) {
		Page<Doctor> pagelist   = ds.findAll(doctor,page,size);
		
		model.addAttribute("doctorList", pagelist.getContent());
		model.addAttribute("pageInfo", pagelist);
		model.addAttribute("doctor", doctor);
		//pagelist.
	    return "admin/doctorList";
	}
	
   /**
	*医生列表 
	*/
	@RequestMapping("/doctorList")
	public String doctorList(Model model,Doctor doctor,@RequestParam(value = "page", defaultValue = "0") int page) {
		Page<Doctor> pagelist   = ds.findAll(doctor,page,size);
		
		model.addAttribute("doctorList", pagelist.getContent());
		model.addAttribute("pageInfo", pagelist);
		model.addAttribute("doctor", doctor);
		//pagelist.
	    return "admin/doctorList";
	}

}
